$(function () {
   var userId = $('#userId').val();
   var contextPath = $('#contextPath').val();
   $.ajax({
        type:'post',
        url:contextPath+'/user/getUserInfo',
        data:{userId:userId},
        success:function (data) {
            if(data.success == true)
            {
                $('#userName').text(data.result.userName);

            }
            else
            {
                alert(data.info);
                return;
            }

        }
    });

   setTimeout(getLoginTimes,100);

   function getLoginTimes() {
       $.ajax({
           type:'post',
           url:contextPath+'/login/getLoginTimes',
           data:{userId:userId},
           success:function (data) {
               if(data.success == true) {

                   if(data.result != null && data.result != "")
                   {
                       var text = "你使用"+data.result.ip+"访问过"+data.result.times+"次";
                       $('#loginTimes').text(text);
                   }
               }
               else
               {
                   alert(data.info);
                   return;
               }

           }
       });
   }

    setTimeout(getUserList,100);

    function getUserList() {
        $.ajax({
            type:'post',
            url:contextPath+'/user/getUserList',
            success:function (data) {
                if(data.success == true) {

                    if(data.result != null && data.result != "")
                    {
                        var list = data.result;
                        for( var i = 0; i < list.length; i++ ) {
                            var tr = '<tr><td>'+list[i].userName+'</td><td>'+list[i].name+'</td><td>'+list[i].times+'</td></tr>';
                            $("#userList").append(tr);
                        }
                    }
                }
                else
                {
                    alert(data.info);
                    return;
                }

            }
        });
    }



});